import IOC.User;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by futao on 2017/8/30.
 */

/**
 * 用默认无参的构造函数直接配置xml创建bean
 */
public class TestIOC {
    @Test
    public void testUser() {
        //加载配置文件
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        //(根据xml配置的id)得到配置创建的对象
        User user = (User) applicationContext.getBean("user");
        System.out.println(user);
        user.add();
    }
}
